package com.meal.base.test.DesignMode.singleton;

/**
 * @program: meal->LasyVoliMode
 * @description: 懒汉模式
 * @author: yangzhanghui
 * @create: 2020-04-03 16:20
 **/
public class LasyVoliMode {

    private volatile static LasyVoliMode lasyVoliMode;

    private LasyVoliMode(){}

    public static LasyVoliMode getInstance() {//庙是开放的不用排队进入
        if (lasyVoliMode == null) {//如果头柱香未产生，这批抢香人进入堂内排队。
            synchronized(LasyVoliMode.class){
                if (lasyVoliMode == null) {//只有头香造了神，其他抢香的白排队了
                    lasyVoliMode = new LasyVoliMode();
                }
            }
        }
        //此处头柱香产生后不必再排队
        return lasyVoliMode;
    }
}
